from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

# 创建一个Chrome浏览器实例
options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)

# 定义HTML和CSS代码
html = """
<!DOCTYPE html>
<html>
<head>
<style>
.box {
  border: 2px solid white;
  width: 200px;
  height: 50px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  color: white;
  font-size: 20px;
  font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<div class="box">
  <div>力量</div>
  <div>基础: 6</div>
</div>
<div class="box">
  <div>智力</div>
  <div>基础: 2</div>
</div>
<div class="box">
  <div>体质</div>
  <div>基础: 6</div>
</div>
<div class="box">
  <div>敏捷</div>
  <div>基础: 6</div>
</div>
</body>
</html>
"""

# 将HTML代码写入文件
with open("attributes.html", "w") as f:
    f.write(html)

# 打开HTML文件并截图
driver.get("file://" + os.path.abspath("attributes.html"))
time.sleep(1)
driver.save_screenshot("attributes.png")

# 关闭浏览器实例
driver.quit()